#ifndef SERVER_H
#define SERVER_H

#include <stdint.h>
#include <set>
#include <string>

#include "network/AbstractSocket.h"
#include "threading/Mutex.h"

class AbstractClient;

class Server : public AbstractSocket
{
    friend class AbstractClient;

public:
                              Server();
                              ~Server();

    bool                      broadcast(void* data, uint32_t size);
    bool                      close();
    bool                      isListening() const;
    bool                      listen(uint16_t port = 31337);
    void                      setMaxPendingConnections(int numConnections);

private:
    Mutex                     mutex_;

    static uint32_t           suiMaxPendingConnections_;

    bool                      bIsListening_;

    std::set<AbstractClient*> clients_;
};

#endif // SERVER_H
